@section('meta')
    <style>
        body{background-color: #fff;}
        .modal-content{display: unset;}
        .layui-form-label {width: 100px;}
        .layui-input-block {margin-left: 138px;}
        .layui-input, .layui-textarea {width: 86%;}
        .layui-input.layui-bg-gray {line-height: 38px;}
        .layui-form-select .layui-edge {right: 16%;}
        .layui-form-select dl {min-width: 86%;}
        .new-table {margin: 20px 0;}
    </style>
@endsection
@include('Home.User.Common._meta')
<div class="modal-content new-table" id="addNew-content2">
    <form class="layui-form modal-client-info" action="" id="form-user" lay-filter="form-user">
        <div class="layui-form-item">
            <label class="layui-form-label">文档标题</label>
            <div class="layui-input-block">
                <div class="layui-input layui-bg-gray">{{$obj->title}}</div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">文档分类</label>
            <div class="layui-input-block">
                <div class="layui-input layui-bg-gray">{{$obj->category_name}}</div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">文档内容</label>
            <div class="layui-input-block">
                <div class="layui-textarea layui-bg-gray"><pre>{{$obj->content}}</pre></div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">文档附件</label>
            <div class="layui-input-block">
                <div class="layui-input layui-bg-gray">@if($obj->file_name)<a href="{{route('knowledge_download',$obj->id)}}" class="check-btn" target="_blank">{{$obj->file_name}}</a>@endif</div>
                @if((Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->uid) && $obj->attachment>0) <br/><a href="javascript:;" class="edit-btn add-schedule" onclick="del('{{route('del_file_knowledge',$obj->id)}}')" title="删除"><i class="layui-icon">&#xe640;</i>删除附件</a>@endif
            </div>

        </div>
    </form>
</div>
<script>
    /*删除*/
    function del(url) {
        layer.confirm("你确定要删除吗？此操作不能撤销！", {icon: 3, title:'提示'},
                function(index){//确定回调
                    $.ajax({
                        type: 'get',
                        url: url,
                        dataType: 'json',
                        success: function(data){
                            if(data.code){
                                window.location.reload();
                                layer.close(index);
                            }else{
                                layer.msg(data.msg,{icon: 5,time:1000});
                            }
                        },
                        error:function() {
                            layer.msg('服务器错误!',{icon: 5,time:1000});
                        }
                    });
                },function (index) {//取消回调
                    layer.close(index);
                }
        );
    }
</script>
@include('Home.User.Common._footer')
@include('Home.User.Common._form')